<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>19.1.12. email.utils: Miscellaneous utilities &mdash; Python 3.4.3 documentation</title>
    
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '3.4.3',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 3.4.3 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="top" title="Python 3.4.3 documentation" href="../index.html" />
    <link rel="up" title="19.1. email — An email and MIME handling package" href="email.html" />
    <link rel="next" title="19.1.13. email.iterators: Iterators" href="email.iterators.html" />
    <link rel="prev" title="19.1.11. email.errors: Exception and Defect classes" href="email.errors.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    <script type="text/javascript" src="../_static/version_switch.js"></script>
    
 

  </head>
  <body>  
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="email.iterators.html" title="19.1.13. email.iterators: Iterators"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="email.errors.html" title="19.1.11. email.errors: Exception and Defect classes"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
        <li>
          <span class="version_switcher_placeholder">3.4.3</span>
          <a href="../index.html">Documentation</a> &raquo;
        </li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="netdata.html" >19. Internet Data Handling</a> &raquo;</li>
          <li><a href="email.html" accesskey="U">19.1. <tt class="docutils literal"><span class="pre">email</span></tt> &#8212; An email and MIME handling package</a> &raquo;</li> 
      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-email.utils">
<span id="email-utils-miscellaneous-utilities"></span><h1>19.1.12. <a class="reference internal" href="#module-email.utils" title="email.utils: Miscellaneous email package utilities."><tt class="xref py py-mod docutils literal"><span class="pre">email.utils</span></tt></a>: Miscellaneous utilities<a class="headerlink" href="#module-email.utils" title="Permalink to this headline">¶</a></h1>
<p>There are several useful utilities provided in the <a class="reference internal" href="#module-email.utils" title="email.utils: Miscellaneous email package utilities."><tt class="xref py py-mod docutils literal"><span class="pre">email.utils</span></tt></a> module:</p>
<dl class="function">
<dt id="email.utils.quote">
<tt class="descclassname">email.utils.</tt><tt class="descname">quote</tt><big>(</big><em>str</em><big>)</big><a class="headerlink" href="#email.utils.quote" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a new string with backslashes in <em>str</em> replaced by two backslashes, and
double quotes replaced by backslash-double quote.</p>
</dd></dl>

<dl class="function">
<dt id="email.utils.unquote">
<tt class="descclassname">email.utils.</tt><tt class="descname">unquote</tt><big>(</big><em>str</em><big>)</big><a class="headerlink" href="#email.utils.unquote" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a new string which is an <em>unquoted</em> version of <em>str</em>. If <em>str</em> ends and
begins with double quotes, they are stripped off.  Likewise if <em>str</em> ends and
begins with angle brackets, they are stripped off.</p>
</dd></dl>

<dl class="function">
<dt id="email.utils.parseaddr">
<tt class="descclassname">email.utils.</tt><tt class="descname">parseaddr</tt><big>(</big><em>address</em><big>)</big><a class="headerlink" href="#email.utils.parseaddr" title="Permalink to this definition">¶</a></dt>
<dd><p>Parse address &#8211; which should be the value of some address-containing field such
as <em class="mailheader">To</em> or <em class="mailheader">Cc</em> &#8211; into its constituent <em>realname</em> and
<em>email address</em> parts.  Returns a tuple of that information, unless the parse
fails, in which case a 2-tuple of <tt class="docutils literal"><span class="pre">('',</span> <span class="pre">'')</span></tt> is returned.</p>
</dd></dl>

<dl class="function">
<dt id="email.utils.formataddr">
<tt class="descclassname">email.utils.</tt><tt class="descname">formataddr</tt><big>(</big><em>pair</em>, <em>charset='utf-8'</em><big>)</big><a class="headerlink" href="#email.utils.formataddr" title="Permalink to this definition">¶</a></dt>
<dd><p>The inverse of <a class="reference internal" href="#email.utils.parseaddr" title="email.utils.parseaddr"><tt class="xref py py-meth docutils literal"><span class="pre">parseaddr()</span></tt></a>, this takes a 2-tuple of the form <tt class="docutils literal"><span class="pre">(realname,</span>
<span class="pre">email_address)</span></tt> and returns the string value suitable for a <em class="mailheader">To</em> or
<em class="mailheader">Cc</em> header.  If the first element of <em>pair</em> is false, then the
second element is returned unmodified.</p>
<p>Optional <em>charset</em> is the character set that will be used in the <span class="target" id="index-0"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2047.html"><strong>RFC 2047</strong></a>
encoding of the <tt class="docutils literal"><span class="pre">realname</span></tt> if the <tt class="docutils literal"><span class="pre">realname</span></tt> contains non-ASCII
characters.  Can be an instance of <a class="reference internal" href="stdtypes.html#str" title="str"><tt class="xref py py-class docutils literal"><span class="pre">str</span></tt></a> or a
<a class="reference internal" href="email.charset.html#email.charset.Charset" title="email.charset.Charset"><tt class="xref py py-class docutils literal"><span class="pre">Charset</span></tt></a>.  Defaults to <tt class="docutils literal"><span class="pre">utf-8</span></tt>.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.3: </span>Added the <em>charset</em> option.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="email.utils.getaddresses">
<tt class="descclassname">email.utils.</tt><tt class="descname">getaddresses</tt><big>(</big><em>fieldvalues</em><big>)</big><a class="headerlink" href="#email.utils.getaddresses" title="Permalink to this definition">¶</a></dt>
<dd><p>This method returns a list of 2-tuples of the form returned by <tt class="docutils literal"><span class="pre">parseaddr()</span></tt>.
<em>fieldvalues</em> is a sequence of header field values as might be returned by
<a class="reference internal" href="email.message.html#email.message.Message.get_all" title="email.message.Message.get_all"><tt class="xref py py-meth docutils literal"><span class="pre">Message.get_all</span></tt></a>.  Here&#8217;s a simple
example that gets all the recipients of a message:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">email.utils</span> <span class="k">import</span> <span class="n">getaddresses</span>

<span class="n">tos</span> <span class="o">=</span> <span class="n">msg</span><span class="o">.</span><span class="n">get_all</span><span class="p">(</span><span class="s">&#39;to&#39;</span><span class="p">,</span> <span class="p">[])</span>
<span class="n">ccs</span> <span class="o">=</span> <span class="n">msg</span><span class="o">.</span><span class="n">get_all</span><span class="p">(</span><span class="s">&#39;cc&#39;</span><span class="p">,</span> <span class="p">[])</span>
<span class="n">resent_tos</span> <span class="o">=</span> <span class="n">msg</span><span class="o">.</span><span class="n">get_all</span><span class="p">(</span><span class="s">&#39;resent-to&#39;</span><span class="p">,</span> <span class="p">[])</span>
<span class="n">resent_ccs</span> <span class="o">=</span> <span class="n">msg</span><span class="o">.</span><span class="n">get_all</span><span class="p">(</span><span class="s">&#39;resent-cc&#39;</span><span class="p">,</span> <span class="p">[])</span>
<span class="n">all_recipients</span> <span class="o">=</span> <span class="n">getaddresses</span><span class="p">(</span><span class="n">tos</span> <span class="o">+</span> <span class="n">ccs</span> <span class="o">+</span> <span class="n">resent_tos</span> <span class="o">+</span> <span class="n">resent_ccs</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="function">
<dt id="email.utils.parsedate">
<tt class="descclassname">email.utils.</tt><tt class="descname">parsedate</tt><big>(</big><em>date</em><big>)</big><a class="headerlink" href="#email.utils.parsedate" title="Permalink to this definition">¶</a></dt>
<dd><p>Attempts to parse a date according to the rules in <span class="target" id="index-1"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a>. however, some
mailers don&#8217;t follow that format as specified, so <a class="reference internal" href="#email.utils.parsedate" title="email.utils.parsedate"><tt class="xref py py-func docutils literal"><span class="pre">parsedate()</span></tt></a> tries to
guess correctly in such cases.  <em>date</em> is a string containing an <span class="target" id="index-2"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a>
date, such as  <tt class="docutils literal"><span class="pre">&quot;Mon,</span> <span class="pre">20</span> <span class="pre">Nov</span> <span class="pre">1995</span> <span class="pre">19:12:08</span> <span class="pre">-0500&quot;</span></tt>.  If it succeeds in parsing
the date, <a class="reference internal" href="#email.utils.parsedate" title="email.utils.parsedate"><tt class="xref py py-func docutils literal"><span class="pre">parsedate()</span></tt></a> returns a 9-tuple that can be passed directly to
<a class="reference internal" href="time.html#time.mktime" title="time.mktime"><tt class="xref py py-func docutils literal"><span class="pre">time.mktime()</span></tt></a>; otherwise <tt class="docutils literal"><span class="pre">None</span></tt> will be returned.  Note that indexes 6,
7, and 8 of the result tuple are not usable.</p>
</dd></dl>

<dl class="function">
<dt id="email.utils.parsedate_tz">
<tt class="descclassname">email.utils.</tt><tt class="descname">parsedate_tz</tt><big>(</big><em>date</em><big>)</big><a class="headerlink" href="#email.utils.parsedate_tz" title="Permalink to this definition">¶</a></dt>
<dd><p>Performs the same function as <a class="reference internal" href="#email.utils.parsedate" title="email.utils.parsedate"><tt class="xref py py-func docutils literal"><span class="pre">parsedate()</span></tt></a>, but returns either <tt class="docutils literal"><span class="pre">None</span></tt> or
a 10-tuple; the first 9 elements make up a tuple that can be passed directly to
<a class="reference internal" href="time.html#time.mktime" title="time.mktime"><tt class="xref py py-func docutils literal"><span class="pre">time.mktime()</span></tt></a>, and the tenth is the offset of the date&#8217;s timezone from UTC
(which is the official term for Greenwich Mean Time) <a class="footnote-reference" href="#id2" id="id1">[1]</a>.  If the input string
has no timezone, the last element of the tuple returned is <tt class="docutils literal"><span class="pre">None</span></tt>.  Note that
indexes 6, 7, and 8 of the result tuple are not usable.</p>
</dd></dl>

<dl class="function">
<dt id="email.utils.parsedate_to_datetime">
<tt class="descclassname">email.utils.</tt><tt class="descname">parsedate_to_datetime</tt><big>(</big><em>date</em><big>)</big><a class="headerlink" href="#email.utils.parsedate_to_datetime" title="Permalink to this definition">¶</a></dt>
<dd><p>The inverse of <a class="reference internal" href="#email.utils.format_datetime" title="email.utils.format_datetime"><tt class="xref py py-func docutils literal"><span class="pre">format_datetime()</span></tt></a>.  Performs the same function as
<a class="reference internal" href="#email.utils.parsedate" title="email.utils.parsedate"><tt class="xref py py-func docutils literal"><span class="pre">parsedate()</span></tt></a>, but on success returns a <a class="reference internal" href="datetime.html#datetime.datetime" title="datetime.datetime"><tt class="xref py py-mod docutils literal"><span class="pre">datetime</span></tt></a>.  If
the input date has a timezone of <tt class="docutils literal"><span class="pre">-0000</span></tt>, the <tt class="docutils literal"><span class="pre">datetime</span></tt> will be a naive
<tt class="docutils literal"><span class="pre">datetime</span></tt>, and if the date is conforming to the RFCs it will represent a
time in UTC but with no indication of the actual source timezone of the
message the date comes from.  If the input date has any other valid timezone
offset, the <tt class="docutils literal"><span class="pre">datetime</span></tt> will be an aware <tt class="docutils literal"><span class="pre">datetime</span></tt> with the
corresponding a <a class="reference internal" href="datetime.html#datetime.timezone" title="datetime.timezone"><tt class="xref py py-class docutils literal"><span class="pre">timezone</span></tt></a> <a class="reference internal" href="datetime.html#datetime.tzinfo" title="datetime.tzinfo"><tt class="xref py py-class docutils literal"><span class="pre">tzinfo</span></tt></a>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="email.utils.mktime_tz">
<tt class="descclassname">email.utils.</tt><tt class="descname">mktime_tz</tt><big>(</big><em>tuple</em><big>)</big><a class="headerlink" href="#email.utils.mktime_tz" title="Permalink to this definition">¶</a></dt>
<dd><p>Turn a 10-tuple as returned by <a class="reference internal" href="#email.utils.parsedate_tz" title="email.utils.parsedate_tz"><tt class="xref py py-func docutils literal"><span class="pre">parsedate_tz()</span></tt></a> into a UTC
timestamp (seconds since the Epoch).  If the timezone item in the
tuple is <tt class="docutils literal"><span class="pre">None</span></tt>, assume local time.</p>
</dd></dl>

<dl class="function">
<dt id="email.utils.formatdate">
<tt class="descclassname">email.utils.</tt><tt class="descname">formatdate</tt><big>(</big><em>timeval=None</em>, <em>localtime=False</em>, <em>usegmt=False</em><big>)</big><a class="headerlink" href="#email.utils.formatdate" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a date string as per <span class="target" id="index-3"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a>, e.g.:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="n">Fri</span><span class="p">,</span> <span class="mi">09</span> <span class="n">Nov</span> <span class="mi">2001</span> <span class="mi">01</span><span class="p">:</span><span class="mi">08</span><span class="p">:</span><span class="mi">47</span> <span class="o">-</span><span class="mi">0000</span>
</pre></div>
</div>
<p>Optional <em>timeval</em> if given is a floating point time value as accepted by
<a class="reference internal" href="time.html#time.gmtime" title="time.gmtime"><tt class="xref py py-func docutils literal"><span class="pre">time.gmtime()</span></tt></a> and <a class="reference internal" href="time.html#time.localtime" title="time.localtime"><tt class="xref py py-func docutils literal"><span class="pre">time.localtime()</span></tt></a>, otherwise the current time is
used.</p>
<p>Optional <em>localtime</em> is a flag that when <tt class="docutils literal"><span class="pre">True</span></tt>, interprets <em>timeval</em>, and
returns a date relative to the local timezone instead of UTC, properly taking
daylight savings time into account. The default is <tt class="docutils literal"><span class="pre">False</span></tt> meaning UTC is
used.</p>
<p>Optional <em>usegmt</em> is a flag that when <tt class="docutils literal"><span class="pre">True</span></tt>, outputs a  date string with the
timezone as an ascii string <tt class="docutils literal"><span class="pre">GMT</span></tt>, rather than a numeric <tt class="docutils literal"><span class="pre">-0000</span></tt>. This is
needed for some protocols (such as HTTP). This only applies when <em>localtime</em> is
<tt class="docutils literal"><span class="pre">False</span></tt>.  The default is <tt class="docutils literal"><span class="pre">False</span></tt>.</p>
</dd></dl>

<dl class="function">
<dt id="email.utils.format_datetime">
<tt class="descclassname">email.utils.</tt><tt class="descname">format_datetime</tt><big>(</big><em>dt</em>, <em>usegmt=False</em><big>)</big><a class="headerlink" href="#email.utils.format_datetime" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <tt class="docutils literal"><span class="pre">formatdate</span></tt>, but the input is a <a class="reference internal" href="datetime.html#module-datetime" title="datetime: Basic date and time types."><tt class="xref py py-mod docutils literal"><span class="pre">datetime</span></tt></a> instance.  If it is
a naive datetime, it is assumed to be &#8220;UTC with no information about the
source timezone&#8221;, and the conventional <tt class="docutils literal"><span class="pre">-0000</span></tt> is used for the timezone.
If it is an aware <tt class="docutils literal"><span class="pre">datetime</span></tt>, then the numeric timezone offset is used.
If it is an aware timezone with offset zero, then <em>usegmt</em> may be set to
<tt class="docutils literal"><span class="pre">True</span></tt>, in which case the string <tt class="docutils literal"><span class="pre">GMT</span></tt> is used instead of the numeric
timezone offset.  This provides a way to generate standards conformant HTTP
date headers.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="email.utils.localtime">
<tt class="descclassname">email.utils.</tt><tt class="descname">localtime</tt><big>(</big><em>dt=None</em><big>)</big><a class="headerlink" href="#email.utils.localtime" title="Permalink to this definition">¶</a></dt>
<dd><p>Return local time as an aware datetime object.  If called without
arguments, return current time.  Otherwise <em>dt</em> argument should be a
<a class="reference internal" href="datetime.html#datetime.datetime" title="datetime.datetime"><tt class="xref py py-class docutils literal"><span class="pre">datetime</span></tt></a> instance, and it is converted to the local time
zone according to the system time zone database.  If <em>dt</em> is naive (that
is, <tt class="docutils literal"><span class="pre">dt.tzinfo</span></tt> is <tt class="docutils literal"><span class="pre">None</span></tt>), it is assumed to be in local time.  In this
case, a positive or zero value for <em>isdst</em> causes <tt class="docutils literal"><span class="pre">localtime</span></tt> to presume
initially that summer time (for example, Daylight Saving Time) is or is not
(respectively) in effect for the specified time.  A negative value for
<em>isdst</em> causes the <tt class="docutils literal"><span class="pre">localtime</span></tt> to attempt to divine whether summer time
is in effect for the specified time.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="email.utils.make_msgid">
<tt class="descclassname">email.utils.</tt><tt class="descname">make_msgid</tt><big>(</big><em>idstring=None</em>, <em>domain=None</em><big>)</big><a class="headerlink" href="#email.utils.make_msgid" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a string suitable for an <span class="target" id="index-4"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a>-compliant
<em class="mailheader">Message-ID</em> header.  Optional <em>idstring</em> if given, is a string
used to strengthen the uniqueness of the message id.  Optional <em>domain</em> if
given provides the portion of the msgid after the &#8216;&#64;&#8217;.  The default is the
local hostname.  It is not normally necessary to override this default, but
may be useful certain cases, such as a constructing distributed system that
uses a consistent domain name across multiple hosts.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.2: </span>Added the <em>domain</em> keyword.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="email.utils.decode_rfc2231">
<tt class="descclassname">email.utils.</tt><tt class="descname">decode_rfc2231</tt><big>(</big><em>s</em><big>)</big><a class="headerlink" href="#email.utils.decode_rfc2231" title="Permalink to this definition">¶</a></dt>
<dd><p>Decode the string <em>s</em> according to <span class="target" id="index-5"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2231.html"><strong>RFC 2231</strong></a>.</p>
</dd></dl>

<dl class="function">
<dt id="email.utils.encode_rfc2231">
<tt class="descclassname">email.utils.</tt><tt class="descname">encode_rfc2231</tt><big>(</big><em>s</em>, <em>charset=None</em>, <em>language=None</em><big>)</big><a class="headerlink" href="#email.utils.encode_rfc2231" title="Permalink to this definition">¶</a></dt>
<dd><p>Encode the string <em>s</em> according to <span class="target" id="index-6"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2231.html"><strong>RFC 2231</strong></a>.  Optional <em>charset</em> and
<em>language</em>, if given is the character set name and language name to use.  If
neither is given, <em>s</em> is returned as-is.  If <em>charset</em> is given but <em>language</em>
is not, the string is encoded using the empty string for <em>language</em>.</p>
</dd></dl>

<dl class="function">
<dt id="email.utils.collapse_rfc2231_value">
<tt class="descclassname">email.utils.</tt><tt class="descname">collapse_rfc2231_value</tt><big>(</big><em>value</em>, <em>errors='replace'</em>, <em>fallback_charset='us-ascii'</em><big>)</big><a class="headerlink" href="#email.utils.collapse_rfc2231_value" title="Permalink to this definition">¶</a></dt>
<dd><p>When a header parameter is encoded in <span class="target" id="index-7"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2231.html"><strong>RFC 2231</strong></a> format,
<a class="reference internal" href="email.message.html#email.message.Message.get_param" title="email.message.Message.get_param"><tt class="xref py py-meth docutils literal"><span class="pre">Message.get_param</span></tt></a> may return a
3-tuple containing the character set,
language, and value.  <a class="reference internal" href="#email.utils.collapse_rfc2231_value" title="email.utils.collapse_rfc2231_value"><tt class="xref py py-func docutils literal"><span class="pre">collapse_rfc2231_value()</span></tt></a> turns this into a unicode
string.  Optional <em>errors</em> is passed to the <em>errors</em> argument of <a class="reference internal" href="stdtypes.html#str" title="str"><tt class="xref py py-class docutils literal"><span class="pre">str</span></tt></a>&#8216;s
<a class="reference internal" href="stdtypes.html#str.encode" title="str.encode"><tt class="xref py py-func docutils literal"><span class="pre">encode()</span></tt></a> method; it defaults to <tt class="docutils literal"><span class="pre">'replace'</span></tt>.  Optional
<em>fallback_charset</em> specifies the character set to use if the one in the
<span class="target" id="index-8"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2231.html"><strong>RFC 2231</strong></a> header is not known by Python; it defaults to <tt class="docutils literal"><span class="pre">'us-ascii'</span></tt>.</p>
<p>For convenience, if the <em>value</em> passed to <a class="reference internal" href="#email.utils.collapse_rfc2231_value" title="email.utils.collapse_rfc2231_value"><tt class="xref py py-func docutils literal"><span class="pre">collapse_rfc2231_value()</span></tt></a> is not
a tuple, it should be a string and it is returned unquoted.</p>
</dd></dl>

<dl class="function">
<dt id="email.utils.decode_params">
<tt class="descclassname">email.utils.</tt><tt class="descname">decode_params</tt><big>(</big><em>params</em><big>)</big><a class="headerlink" href="#email.utils.decode_params" title="Permalink to this definition">¶</a></dt>
<dd><p>Decode parameters list according to <span class="target" id="index-9"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2231.html"><strong>RFC 2231</strong></a>.  <em>params</em> is a sequence of
2-tuples containing elements of the form <tt class="docutils literal"><span class="pre">(content-type,</span> <span class="pre">string-value)</span></tt>.</p>
</dd></dl>

<p class="rubric">Footnotes</p>
<table class="docutils footnote" frame="void" id="id2" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>Note that the sign of the timezone offset is the opposite of the sign of the
<tt class="docutils literal"><span class="pre">time.timezone</span></tt> variable for the same timezone; the latter variable follows
the POSIX standard while this module follows <span class="target" id="index-10"></span><a class="rfc reference external" href="http://tools.ietf.org/html/rfc2822.html"><strong>RFC 2822</strong></a>.</td></tr>
</tbody>
</table>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="email.errors.html"
                        title="previous chapter">19.1.11. <tt class="docutils literal"><span class="pre">email.errors</span></tt>: Exception and Defect classes</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="email.iterators.html"
                        title="next chapter">19.1.13. <tt class="docutils literal"><span class="pre">email.iterators</span></tt>: Iterators</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
  <li><a href="../bugs.html">Report a Bug</a></li>
  <li><a href="../_sources/library/email.util.txt"
         rel="nofollow">Show Source</a></li>
</ul>

<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="email.iterators.html" title="19.1.13. email.iterators: Iterators"
             >next</a> |</li>
        <li class="right" >
          <a href="email.errors.html" title="19.1.11. email.errors: Exception and Defect classes"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
        <li>
          <span class="version_switcher_placeholder">3.4.3</span>
          <a href="../index.html">Documentation</a> &raquo;
        </li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="netdata.html" >19. Internet Data Handling</a> &raquo;</li>
          <li><a href="email.html" >19.1. <tt class="docutils literal"><span class="pre">email</span></tt> &#8212; An email and MIME handling package</a> &raquo;</li> 
      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2015, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Feb 26, 2015.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2.3.
    </div>

  </body>
</html>